(function(vc){
    vc.extends({
        propTypes: {
           emitChooseShopReturnAddress:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseShopReturnAddressInfo:{
                shopReturnAddresss:[],
                _currentShopReturnAddressName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseShopReturnAddress','openChooseShopReturnAddressModel',function(_param){
                $('#chooseShopReturnAddressModel').modal('show');
                $that._refreshChooseShopReturnAddressInfo();
                $that._loadAllShopReturnAddressInfo(1,10,'');
            });
        },
        methods:{
            _loadAllShopReturnAddressInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('shopReturnAddress.listShopReturnAddresss',
                             param,
                             function(json){
                                var _shopReturnAddressInfo = JSON.parse(json);
                                $that.chooseShopReturnAddressInfo.shopReturnAddresss = _shopReturnAddressInfo.shopReturnAddresss;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseShopReturnAddress:function(_shopReturnAddress){
                if(_shopReturnAddress.hasOwnProperty('name')){
                     _shopReturnAddress.shopReturnAddressName = _shopReturnAddress.name;
                }
                vc.emit($props.emitChooseShopReturnAddress,'chooseShopReturnAddress',_shopReturnAddress);
                vc.emit($props.emitLoadData,'listShopReturnAddressData',{
                    shopReturnAddressId:_shopReturnAddress.shopReturnAddressId
                });
                $('#chooseShopReturnAddressModel').modal('hide');
            },
            queryShopReturnAddresss:function(){
                $that._loadAllShopReturnAddressInfo(1,10,$that.chooseShopReturnAddressInfo._currentShopReturnAddressName);
            },
            _refreshChooseShopReturnAddressInfo:function(){
                $that.chooseShopReturnAddressInfo._currentShopReturnAddressName = "";
            }
        }

    });
})(window.vc);
